package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * 该controller控制体检预约的部分请求
 */
@RestController
@RequestMapping("/mobile/setmeal")
@Slf4j
public class MobileSetmealController {

    @Autowired
    private SetMealService setMealService;

    @GetMapping("/getSetmeal")
    public Result getSetmeal(){
        //调用DAO层查询并返回
        ArrayList<Setmeal> setmeals = setMealService.findAll();
        //构造返回结果并返回
        return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS,setmeals);
    }

    @GetMapping("/findById")
    public Result findById(Integer id){
        //调用DAO层查询并返回
        Setmeal setmeals= setMealService.findById(id);
        //构造返回结果并返回
        return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS,setmeals);
    }
}
